<?php
namespace app\massage\model;

use app\BaseModel;
use think\db\exception\{
    DbException,
    DataNotFoundException,
    ModelNotFoundException
};

class BalanceCardDiscount extends BaseModel
{
    protected $name = 'massage_service_balance_card_discount';

    /**
     * @throws DbException
     */
    public function dataList($dis, $page = 10): array
    {
        return $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
    }

    /**
     * @throws DbException
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     */
    public function dataInfo($dis): array
    {
        $data = $this->where($dis)->find();

        return !empty($data) ? $data->toArray() : [];
    }

    public function dataAdd($data)
    {
        $data['create_time'] = time();

        return $this->insert($data);
    }

    public function dataUpdate($dis,$data)
    {
        return $this->where($dis)->update($data);
    }
}
